#namespace("com.htwy.core.model.Account")
  #sql("findByCondition")
    SELECT uuid, account, name, phone, email, password, salt, rank, status, orgnazation, creator, createTime, mender, modifyTime, deletedBy, deletedMarker, deleteTime
    FROM ht_sys_account
    #WHERE()
      #if(uuid)
        uuid = #para(uuid)
      #end
      #if(account)
        AND account = #para(account)
      #end
      #if(name)
        AND name = #para(name)
      #end
      #if(phone)
        AND phone = #para(phone)
      #end
      #if(email)
        AND email = #para(email)
      #end
      #if(password)
        AND password = #para(password)
      #end
      #if(salt)
        AND salt = #para(salt)
      #end
      #if(rank)
        AND rank = #para(rank)
      #end
      #if(status)
        AND status = #para(status)
      #end
      #if(orgnazation)
        AND orgnazation = #para(orgnazation)
      #end
      #if(creator)
        AND creator = #para(creator)
      #end
      #if(createTime)
        AND createTime = #para(createTime)
      #end
      #if(mender)
        AND mender = #para(mender)
      #end
      #if(modifyTime)
        AND modifyTime = #para(modifyTime)
      #end
      #if(deletedBy)
        AND deletedBy = #para(deletedBy)
      #end
      #if(deletedMarker)
        AND deletedMarker = #para(deletedMarker)
      #end
      #if(deleteTime)
        AND deleteTime = #para(deleteTime)
      #end
      #if(roleId)
        AND uuid IN (SELECT accountId FROM ht_sys_r_account_role WHERE roleId = #para(roleId) )
      #end
    #end
    ORDER BY account asc
    
  #end

  #sql("deleteByPks")
    DELETE FROM ht_sys_account
    #WHERE()
      #if(pks != null && pks.length > 0)
        #if(pks.length>1)
          uuid in (
          #for(tempId : pks)
            #if(for.first)
              #para(tempId)
            #else
              , #para(tempId)
            #end
          #end
          )
        #else
          uuid = #para(pks[0])
        #end
      #end
    #end
  #end

  #sql("findByUsername")
      SELECT uuid, account, name, phone, email, password, salt, rank, status, orgnazation, creator, createTime, mender, modifyTime, deletedBy, deletedMarker, deleteTime
      FROM ht_sys_account
      #WHERE()
        #if(account)
          account = #para(account)
        #end
      #end
  #end

  #sql("getRoleIdsByAccountId")
    SELECT roleId FROM ht_sys_r_account_role WHERE accountId = #para(accountId)
  #end

  #sql("deleteRolesByAccountId")
    DELETE FROM  ht_sys_r_account_role WHERE accountId = #para(accountId)
  #end

  #sql("addAccountRole")
    INSERT INTO ht_sys_r_account_role (uuid, accountId, roleId) values (#para(uuid), #para(accountId), #para(roleId))
  #end

#end